package com.xiaobai.rest;

import com.xiaobai.service.OpenFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/vid")
public class ConsulVidController {


    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping("/getVid")
    public String getUser(String id) {

        // RestTemplate restTemplate=new RestTemplate();
        //根据视频id返回用户信息
        String forObject = restTemplate.getForObject("http://localhost:8001/user/getUser?id="+id, String.class);

        System.out.println(forObject);
        return "根据视频id查询 用户信息:" + forObject;
    }

    @Autowired
    private OpenFeignService openFeignService;

    /**
     * feigen 调用
     * @param id
     * @return
     */
    @RequestMapping("/getVidfeign")
    public String feigen(String id) {

        //feign远程调用
        String userInfo = openFeignService.getUserInfo(id);
        System.out.println(userInfo);
        return "根据视频id查询 用户信息:" + userInfo;
    }



}
